/*
 * @Descripttion: 字段描述
 * @Author: is_Hsf
 * @Date: 2023-05-26 15:45:16
 * @LastEditTime: 2023-06-15 16:23:10
 */
const CompressionPlugin = require('compression-webpack-plugin')
const AutoImport = require('unplugin-auto-import/webpack').default;

module.exports = {
	// publicPath: process.env.NODE_ENV === 'development' ? '/' : "/vue-admin-work-x",
	publicPath: '/',
	outputDir: 'dist',
	assetsDir: 'static',
	lintOnSave: true,
	productionSourceMap: false,
	devServer: {
		hot: true,
		port: 5567,
		open: true,
		overlay: {
			warnings: false, //黄色警告
			errors: true
		},

	},
	configureWebpack: {
		devtool: 'source-map',
		module: {
			rules: [
				{
					test: /\.mjs$/,
					include: /node_modules/,
					type: 'javascript/auto'
				}
			],
			
		},	plugins: [
			AutoImport({
                imports: [
                    'vue',
                    'vue-router',
                    'vuex',
                    '@vueuse/core',
                    {
                        'element-plus': [
                            'ElMessage',
                            'ElMessageBox'
                        ]
                    }
                ],
                dts: 'src/auto-imports.d.ts', // 指定生成的声明文件位置
            })
		  ],
	},

	chainWebpack(config) {
		config.plugin('html').tap(args => {
			args[0].title = 'admin_log'
			return args
		})
		if (process.env.NODE_ENV === 'production') {
			config.plugin('compressionPlugin').use(
				new CompressionPlugin({
					filename: '[path].gz[query]',
					algorithm: 'gzip',
					test: /\.js$|\.html$|\.css/,
					threshold: 50240,
					deleteOriginalAssets: false
				})
			)
		}
	}
}
